Ext.BLANK_IMAGE_URL='/wsd/image/page/s.gif';
Ext.onReady(function(){
	
	var userNameField = new Ext.form.TextField({
		fieldLabel:'用户名(*)',
		name:'user.username',
		blankText:'用户名不能为空',
		msgTarget:'under',
		allowBlank:false
	})
	
	var nameField = new Ext.form.TextField({
		fieldLabel:'姓名(*)',
		name:'user.UName',
		blankText:'用户姓名不能为空',
		msgTarget:'under',
		allowBlank:false
	})
	var emailField = new Ext.form.TextField({
		fieldLabel:'用户邮箱',
		name:'user.email',
		width:200
	})
	var mobileField = new Ext.form.TextField({
		fieldLabel:'手机(*)',
		name:'user.mobile',
		blankText:'用户手机不能为空',
		msgTarget:'under',
		allowBlank:false
	})
	var phoneField = new Ext.form.NumberField({
			fieldLabel:'座机',
			name:'user.phone',
			msgTarget:'under'
		})
	var userTypeCombo = new Ext.form.ComboBox({
		fieldLabel:'会员类型',
		mode:'local',
		name:'text',
		triggerAction:'all',
		valueField:'user.userLevel',
		displayField:'userLevel',
		value:1,
		editable:false,
		store:new Ext.data.SimpleStore({
			fields:['user.userLevel','userLevel'],
			data:[
				['1','普通会员'],
				['2','高级会员'],
				['3','VIP会员']
			]
		})
	})
	var addressField = new Ext.form.TextField({
		fieldLabel:'地址(*)',
		name:'user.address',
		blankText:'地址不能为空',
		msgTarget:'under',
		allowBlank:false,
		width:300
	})
	var companyField = new Ext.form.TextField({
		fieldLabel:'公司(*)',
		allowBlank:false,
		blankText:'公司名不能为空',
		msgTarget:'under',
		name:'user.company'
	})
	var commentField = new Ext.form.TextArea({
		fieldLabel:'备注',
		name:'user.comment',
		width:300,
		height:100
	})
	var addBtn = new Ext.Button({
		text:'添加',
		handler:add
	})
	var resetBtn = new Ext.Button({
		text:'重置',
		handler:function(){
			form.getForm().reset();
		}
	})
	var form = new Ext.FormPanel({
		region:'center',
		frame:true,
		items:[userNameField,nameField,emailField,mobileField,phoneField,userTypeCombo,addressField,companyField,commentField],
		buttons:[addBtn,resetBtn]
	})
	var viewport = new Ext.Viewport({
		layout : 'border',
		frame:true,
		items : [form]
	});
	
	function add(){
		form.getForm().submit({
			url:'admin/user_add.action',
			params:{
				'user.userLevel':userTypeCombo.getValue()
			},
			waitMsg: '系统正在处理，请稍后……',
            success: function(fp, o){
		        Ext.Msg.alert('系统信息',"添加成功,初始密码为123456");
            },
            failure:function(fp, o){
            	Ext.Msg.alert('系统信息',o.result.result.msg);
            }
		})
	}
	
});